/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2024-02-02
 * Time: 12:32
 *
 * https://www.nowcoder.com/share/jump/7745334641706848383295
 */
public class BM87 {
    public void merge(int[] A, int m, int[] B, int n) {
        int a = m - 1, b = n - 1, i = m + n - 1;
        while (a >= 0 && b >= 0) {
            if (A[a] > B[b]) {
                A[i] = A[a--];
            } else {
                A[i] = B[b--];
            }
            i--;
        }
        while (b >= 0) {
            A[i--] = B[b--];
        }
    }
}
